package com.lry.rpc.netty.processor;

import com.lry.protocol.RpcMessage;
import com.lry.rpc.netty.client.ClientCache;
import com.lry.spi.LoadLevel;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@LoadLevel(name = "rpc_response")
public class RpcResponseProcessor implements Processor{
    @Override
    public void process(Channel channel, RpcMessage request) {
        RpcMessage cache = ClientCache.removeRpcMessageByRequestId(request.getRequestId());
        if(null!=cache){
            synchronized (cache){
                cache.setBody(request.getBody());
                cache.notifyAll();
            }
        }
    }
}
